package run;

import IGUI.Publisher;
import IGUI.Subscriber;
import IUSECASE.IUC_Factory;
import bo.ListeClients;
import bo.ListeEmployesInterne;
import bo.ListeInterventions;
import bo.ListeInterventions;
import bo.ListeTechniciens;
import boerrors.ClientParticulierInexistantException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.text.DateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import usecase.FactoryUC;

public class Frm_ServerRun extends javax.swing.JFrame implements Subscriber{
 
    private String url = null;;
    private DefaultListModel _modeleServerStatus = new DefaultListModel();
    private DefaultListModel _modeleClientsConnection = new DefaultListModel();
    private IUC_Factory factory = null;
    GregorianCalendar date = new GregorianCalendar();
    
    private void rebind(){
        try {
            this.url = "rmi://" + jtxt_ServerName.getText() + ":" + jtxt_ServerPort.getText() + "/" + jtxt_ServerDirectory.getText();
            LocateRegistry.getRegistry(Integer.parseInt(jtxt_ServerPort.getText()));
            this._modeleServerStatus.addElement(date.getTime() + ": " + LocateRegistry.getRegistry().toString());
            this._modeleServerStatus.addElement(date.getTime() + ": RMI Registry server creation: OK");
            //FactoryUC.register();
            factory = FactoryUC.getInstance();
            this._modeleServerStatus.addElement(date.getTime() + ": UC_Factory instancied: OK");
            Naming.rebind(this.url, factory);
            this._modeleServerStatus.addElement(date.getTime() + ": Factory Instance Reference:");
            this._modeleServerStatus.addElement(date.getTime() + ": ==>" + factory.toString());
            jbtn_Start.setEnabled(false);
            jbtn_Stop.setEnabled(true);
            InetAddress Ip = InetAddress.getLocalHost();
            jtxt_INomServeur.setText(Ip.getHostName());
            jtxt_IpAdress.setText(Ip.getHostAddress());
            this._modeleServerStatus.addElement("--------------------[START SERVER]---------------------");           
        } catch (UnknownHostException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    /** Creates new form Frm_ServerRun */
    public Frm_ServerRun() {
        try {
            initComponents();
            ((Publisher) FactoryUC.getInstance()).subscribeSrv((Subscriber) this);
            ((Publisher) ListeInterventions.getInstance()).subscribeSrv((Subscriber) this);
            ((Publisher) ListeClients.getInstance()).subscribeSrv((Subscriber) this);
            ((Publisher) ListeEmployesInterne.getInstance()).subscribeSrv((Subscriber) this);
            ((Publisher) ListeTechniciens.getInstance()).subscribeSrv((Subscriber) this);            
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
     
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel18 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jtxt_ServerName = new javax.swing.JTextField();
        jtxt_ServerPort = new javax.swing.JTextField();
        jtxt_ServerDirectory = new javax.swing.JTextField();
        jbtn_Stop = new javax.swing.JButton();
        jbtn_Start = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        jbtn_ServerRefresh = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        jbtn_ServerClear = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jPanel4 = new javax.swing.JPanel();
        jToolBar2 = new javax.swing.JToolBar();
        jButton1 = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        jScrollPane2 = new javax.swing.JScrollPane();
        jl_ConnectionStatus = new javax.swing.JList();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jtxt_NombreCltP = new javax.swing.JTextField();
        jbtn_RafraichirLCP = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jtxt_NombreCltS = new javax.swing.JTextField();
        jbtn_RafraichirLCS = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jtxt_NbrTechniciens = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jbtn_RafraichirNbrTech = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jtxt_NbrEmpInt = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jbtn_RafraichirNbrEmpInt = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jtxt_Clients = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jbtn_RafraichirClients = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jtxt_NbrInterventions = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jbtn_NbrInterventions = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jtxt_INomServeur = new javax.swing.JTextField();
        jtxt_IpAdress = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jtxt_NbrConnection2 = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        jLabel18.setText("jLabel18");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Console Server");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Connections"));

        jLabel1.setText("Nom du serveur:");

        jLabel2.setText("Port du serveur:");

        jLabel3.setText("Directory:");

        jtxt_ServerName.setText("127.0.0.1");

        jtxt_ServerPort.setText("1099");

        jtxt_ServerDirectory.setText("factory");

        jbtn_Stop.setText("Stop");
        jbtn_Stop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_StopActionPerformed(evt);
            }
        });

        jbtn_Start.setText("Start");
        jbtn_Start.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_StartActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jbtn_Start)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtn_Stop))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxt_ServerPort, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxt_ServerName, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(35, 35, 35)
                        .addComponent(jtxt_ServerDirectory, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxt_ServerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxt_ServerPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxt_ServerDirectory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtn_Stop)
                    .addComponent(jbtn_Start))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        jToolBar1.setRollover(true);

        jbtn_ServerRefresh.setText("Rafraichir");
        jbtn_ServerRefresh.setFocusable(false);
        jbtn_ServerRefresh.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbtn_ServerRefresh.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jbtn_ServerRefresh);
        jToolBar1.add(jSeparator1);

        jbtn_ServerClear.setText("Effacer");
        jbtn_ServerClear.setFocusable(false);
        jbtn_ServerClear.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbtn_ServerClear.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtn_ServerClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_ServerClearActionPerformed(evt);
            }
        });
        jToolBar1.add(jbtn_ServerClear);

        jList1.setModel(_modeleServerStatus);
        jScrollPane1.setViewportView(jList1);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 676, Short.MAX_VALUE)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Serveur Status", jPanel3);

        jToolBar2.setRollover(true);

        jButton1.setText("Refresh");
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jToolBar2.add(jButton1);
        jToolBar2.add(jSeparator2);

        jl_ConnectionStatus.setModel(_modeleClientsConnection);
        jScrollPane2.setViewportView(jl_ConnectionStatus);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 676, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Connections Status", jPanel4);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Listes informations"));

        jLabel4.setText("Liste de clients Particulier:");

        jtxt_NombreCltP.setEditable(false);

        jbtn_RafraichirLCP.setText("Rafraichir");
        jbtn_RafraichirLCP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_RafraichirLCPActionPerformed(evt);
            }
        });

        jLabel5.setText("Liste de clients Sociétés:");

        jtxt_NombreCltS.setEditable(false);

        jbtn_RafraichirLCS.setText("Rafraichir");
        jbtn_RafraichirLCS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_RafraichirLCSActionPerformed(evt);
            }
        });

        jButton2.setText("Liste DB");

        jButton3.setText("Liste Serveur");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Liste DB");

        jButton5.setText("Liste Serveur");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel6.setText("élément(s)");

        jLabel7.setText("élément(s)");

        jLabel8.setText("Liste des Technciens:");

        jtxt_NbrTechniciens.setEditable(false);

        jLabel9.setText("élément(s)");

        jbtn_RafraichirNbrTech.setText("Rafraichir");
        jbtn_RafraichirNbrTech.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_RafraichirNbrTechActionPerformed(evt);
            }
        });

        jButton7.setText("Liste DB");

        jButton8.setText("Liste Serveur");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jLabel10.setText("Liste des Employes Int.:");

        jtxt_NbrEmpInt.setEditable(false);

        jLabel11.setText("élément(s)");

        jbtn_RafraichirNbrEmpInt.setText("Rafraichir");
        jbtn_RafraichirNbrEmpInt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_RafraichirNbrEmpIntActionPerformed(evt);
            }
        });

        jButton9.setText("Liste DB");

        jButton10.setText("Liste Serveur");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jLabel12.setText("Liste des clients:");

        jtxt_Clients.setEditable(false);

        jLabel13.setText("élément(s)");

        jbtn_RafraichirClients.setText("Rafraichir");
        jbtn_RafraichirClients.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_RafraichirClientsActionPerformed(evt);
            }
        });

        jButton11.setText("Liste DB");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jButton12.setText("Liste Serveur");

        jLabel14.setText("Liste des interventions:");

        jtxt_NbrInterventions.setEditable(false);

        jLabel15.setText("élément(s)");

        jbtn_NbrInterventions.setText("Rafraichir");
        jbtn_NbrInterventions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_NbrInterventionsActionPerformed(evt);
            }
        });

        jButton13.setText("Liste DB");

        jButton14.setText("Liste Serveur");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14)
                    .addComponent(jLabel12)
                    .addComponent(jLabel10)
                    .addComponent(jLabel8)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtxt_NbrInterventions, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)
                    .addComponent(jtxt_Clients, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)
                    .addComponent(jtxt_NbrEmpInt, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)
                    .addComponent(jtxt_NbrTechniciens, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)
                    .addComponent(jtxt_NombreCltS, 0, 0, Short.MAX_VALUE)
                    .addComponent(jtxt_NombreCltP, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(jLabel13)
                    .addComponent(jLabel11)
                    .addComponent(jLabel9)
                    .addComponent(jLabel7)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbtn_RafraichirLCS, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                    .addComponent(jbtn_RafraichirNbrTech, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                    .addComponent(jbtn_RafraichirNbrEmpInt, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                    .addComponent(jbtn_RafraichirClients, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                    .addComponent(jbtn_NbrInterventions, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                    .addComponent(jbtn_RafraichirLCP, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton13)
                    .addComponent(jButton11)
                    .addComponent(jButton9)
                    .addComponent(jButton7)
                    .addComponent(jButton4)
                    .addComponent(jButton2))
                .addGap(8, 8, 8)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton14, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                    .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                    .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                    .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                    .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel4)
                    .addComponent(jButton3)
                    .addComponent(jLabel6)
                    .addComponent(jButton2)
                    .addComponent(jtxt_NombreCltP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_RafraichirLCP))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel5)
                    .addComponent(jtxt_NombreCltS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_RafraichirLCS)
                    .addComponent(jButton4)
                    .addComponent(jButton5)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jbtn_RafraichirNbrTech)
                    .addComponent(jButton7)
                    .addComponent(jButton8)
                    .addComponent(jtxt_NbrTechniciens, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jButton10)
                    .addComponent(jButton9)
                    .addComponent(jbtn_RafraichirNbrEmpInt)
                    .addComponent(jLabel11)
                    .addComponent(jtxt_NbrEmpInt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jtxt_Clients, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(jButton12)
                    .addComponent(jButton11)
                    .addComponent(jbtn_RafraichirClients))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jtxt_NbrInterventions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(jButton14)
                    .addComponent(jButton13)
                    .addComponent(jbtn_NbrInterventions))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(48, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Object Status", jPanel2);

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Informations"));

        jLabel17.setText("Nom du serveur:");

        jLabel19.setText("Adresse IP:");

        jtxt_INomServeur.setEditable(false);

        jtxt_IpAdress.setEditable(false);

        jLabel20.setText("Nombre de connections:");

        jtxt_NbrConnection2.setEditable(false);
        jtxt_NbrConnection2.setText("0");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel17)
                            .addComponent(jLabel19))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtxt_IpAdress, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
                            .addComponent(jtxt_INomServeur, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel20)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxt_NbrConnection2, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jtxt_INomServeur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxt_IpAdress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19))
                .addGap(8, 8, 8)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtxt_NbrConnection2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20))
                .addContainerGap(56, Short.MAX_VALUE))
        );

        jMenu1.setText("File");

        jMenuItem1.setText("Quitter");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 681, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtn_StartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_StartActionPerformed
       /*if (System.getSecurityManager() == null) {
                    System.setProperty("java.security.policy", "c:\\NetBeans\\java.policy"); 
                    System.setSecurityManager(new RMISecurityManager());
                    this._modeleServerStatus.addElement("java.policy chargé ==> Ok");
       }*/
        try {
            DateFormat dateFormat = DateFormat.getDateInstance();
            this._modeleServerStatus.addElement("--------------------[START SERVER]---------------------");
            this._modeleServerStatus.addElement("Format de date: " + dateFormat.format(new Date()));
            this.url = "rmi://" + jtxt_ServerName.getText() + ":" + jtxt_ServerPort.getText() + "/" + jtxt_ServerDirectory.getText();
            LocateRegistry.createRegistry(Integer.parseInt(jtxt_ServerPort.getText()));
            this._modeleServerStatus.addElement(LocateRegistry.getRegistry().toString());
            this._modeleServerStatus.addElement(date.getTime() + ": RMI Registry server creation: OK");
            //FactoryUC.register();
            factory = FactoryUC.getInstance();
            this._modeleServerStatus.addElement(date.getTime() + ": UC_Factory instancied: OK");
            Naming.rebind(this.url, factory);
            this._modeleServerStatus.addElement(date.getTime() + ": Factory Instance Reference:");
            this._modeleServerStatus.addElement(date.getTime() + ": ==>" + factory.toString());
            jbtn_Start.setEnabled(false);
            jbtn_Stop.setEnabled(true);
            InetAddress Ip =InetAddress.getLocalHost();
            jtxt_INomServeur.setText(Ip.getHostName());
            jtxt_IpAdress.setText(Ip.getHostAddress());
            this._modeleServerStatus.addElement("--------------------[START SERVER]---------------------");            
        } catch (UnknownHostException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            this._modeleServerStatus.addElement(date.getTime() + ": RMI Registry server creation: FAILED");
            this._modeleServerStatus.addElement(date.getTime() + ": RMI Registry server creation: Try rebinding process");
            rebind();
        } catch (MalformedURLException ex) {
            this._modeleServerStatus.addElement(date.getTime() + ": RMI Binding: FAILED");
            this._modeleServerStatus.addElement("--------------------[START SERVER]---------------------");
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }        
        
    }//GEN-LAST:event_jbtn_StartActionPerformed

    private void jbtn_ServerClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_ServerClearActionPerformed

if (JOptionPane.showConfirmDialog(null, "Etes vous sure de vouloir supprimer le loggin?","Question",JOptionPane.YES_NO_OPTION ) == 0)
    this._modeleServerStatus.removeAllElements();
        
    }//GEN-LAST:event_jbtn_ServerClearActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jbtn_RafraichirLCSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_RafraichirLCSActionPerformed
        try {

            jtxt_NombreCltS.setText(String.valueOf(bo.ListeClients.getInstance().nombreDeClientsSociete()));
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
        
}//GEN-LAST:event_jbtn_RafraichirLCSActionPerformed

    private void jbtn_RafraichirLCPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_RafraichirLCPActionPerformed
        try {

            jtxt_NombreCltP.setText(String.valueOf(bo.ListeClients.getInstance().nombreDeClientsParticulier()));
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_jbtn_RafraichirLCPActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed

        System.exit(0);
        
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jbtn_RafraichirNbrTechActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_RafraichirNbrTechActionPerformed
        try {

            jtxt_NbrTechniciens.setText(String.valueOf(bo.ListeTechniciens.getInstance().nombreDeTechnicien()));
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_jbtn_RafraichirNbrTechActionPerformed

    private void jbtn_RafraichirNbrEmpIntActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_RafraichirNbrEmpIntActionPerformed
        try {

            jtxt_NbrEmpInt.setText(String.valueOf(bo.ListeEmployesInterne.getInstance().nombreEmployesInterne()));
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
        
}//GEN-LAST:event_jbtn_RafraichirNbrEmpIntActionPerformed

    private void jbtn_RafraichirClientsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_RafraichirClientsActionPerformed
        try {

            jtxt_Clients.setText(String.valueOf(bo.ListeClients.getInstance().nombreDeClients()));
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
        
}//GEN-LAST:event_jbtn_RafraichirClientsActionPerformed

    private void jbtn_NbrInterventionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_NbrInterventionsActionPerformed
        try {

            jtxt_NbrInterventions.setText(String.valueOf(bo.ListeInterventions.getInstance().nombreInterventions()));
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
        
}//GEN-LAST:event_jbtn_NbrInterventionsActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed


        
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed

        Jd_ListesInterventions objListe = new Jd_ListesInterventions(null, false);
        objListe.setVisible(true);
        
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jbtn_StopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_StopActionPerformed
        try {
            
            //Naming.rebind(this.url, factory);
            this._modeleServerStatus.addElement("---------------------[STOP SERVER]---------------------");
            this._modeleServerStatus.addElement(date.getTime() + ": Unbinding Rmi server in progress");
            Naming.unbind(this.url);
            this._modeleServerStatus.addElement(date.getTime() + ": Unbind Rmi server ==> OK");
            jtxt_INomServeur.setText("");
            jtxt_IpAdress.setText("");
            ListeClients.getInstance().unSubscribeAllSubscribers();
            this._modeleServerStatus.addElement(date.getTime() + ": ListeClients remove all subscribers ==> OK");
            ListeEmployesInterne.getInstance().unSubscribeAllSubscribers();
            this._modeleServerStatus.addElement(date.getTime() + ": ListeEmployesInterne remove all subscribers ==> OK");
            ListeInterventions.getInstance().unSubscribeAllSubscribers();
            this._modeleServerStatus.addElement(date.getTime() + ": ListeInterventions remove all subscribers ==> OK");
            ListeTechniciens.getInstance().unSubscribeAllSubscribers();
            this._modeleServerStatus.addElement(date.getTime() + ": ListeTechniciens remove all subscribers ==> OK");
            this.jbtn_Start.setEnabled(true);
            this.jbtn_Stop.setEnabled(false);
            this._modeleServerStatus.addElement("---------------------[STOP SERVER]---------------------");
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NotBoundException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
    }//GEN-LAST:event_jbtn_StopActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

        Jd_ListeClientsParticulier obj = new Jd_ListeClientsParticulier(null, false);
        obj.setVisible(true);
        
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

        Jd_ListeClientsSociete obj = new Jd_ListeClientsSociete(null, false);
        obj.setVisible(true);       
        
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed

        Jd_ListeTechniciens obj = new Jd_ListeTechniciens(null, false);
        obj.setVisible(true);        
        
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed

        Jd_ListeEmployesInt obj = new Jd_ListeEmployesInt(null, false);
        obj.setVisible(true);         
        
    }//GEN-LAST:event_jButton10ActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    //Init
                    new Frm_ServerRun().setVisible(true);
                    initServer();                    
                } catch (Exception ex) {
                    Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    
    private static void initServer() {
        try {
            dao.impl.FactoryImpl.enregistrer();
            bo.ListeClients.getInstance().remplirListeClientsParticulier(bo.ClientParticulier.lister());
            bo.ListeClients.getInstance().remplirListeClientsSociete(bo.ClientSociete.lister());
            //bo.ListeClients.getInstance().remplirListeClients();
            bo.ListeTechniciens.getInstance().remplirListeTechnicien(bo.Technicien.lister());
            bo.ListeEmployesInterne.getInstance().remplirListeEmployeInterne(bo.EmployeInterne.lister());
            bo.ListeInterventions.getInstance().remplirListeIntervention(bo.Intervention.lister());
        } catch (RemoteException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClientParticulierInexistantException ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(Frm_ServerRun.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JButton jbtn_NbrInterventions;
    private javax.swing.JButton jbtn_RafraichirClients;
    private javax.swing.JButton jbtn_RafraichirLCP;
    private javax.swing.JButton jbtn_RafraichirLCS;
    private javax.swing.JButton jbtn_RafraichirNbrEmpInt;
    private javax.swing.JButton jbtn_RafraichirNbrTech;
    private javax.swing.JButton jbtn_ServerClear;
    private javax.swing.JButton jbtn_ServerRefresh;
    private javax.swing.JButton jbtn_Start;
    private javax.swing.JButton jbtn_Stop;
    private javax.swing.JList jl_ConnectionStatus;
    private javax.swing.JTextField jtxt_Clients;
    private javax.swing.JTextField jtxt_INomServeur;
    private javax.swing.JTextField jtxt_IpAdress;
    private javax.swing.JTextField jtxt_NbrConnection2;
    private javax.swing.JTextField jtxt_NbrEmpInt;
    private javax.swing.JTextField jtxt_NbrInterventions;
    private javax.swing.JTextField jtxt_NbrTechniciens;
    private javax.swing.JTextField jtxt_NombreCltP;
    private javax.swing.JTextField jtxt_NombreCltS;
    private javax.swing.JTextField jtxt_ServerDirectory;
    private javax.swing.JTextField jtxt_ServerName;
    private javax.swing.JTextField jtxt_ServerPort;
    // End of variables declaration//GEN-END:variables

    public void update(Object object) throws RemoteException {
        this._modeleClientsConnection.addElement("-----------------------------------");
        this._modeleClientsConnection.addElement("DEBUG MVC:");
        this._modeleClientsConnection.addElement("Object Class: " + object.getClass());
        this._modeleClientsConnection.addElement("Object Class [name]: " + object.getClass().getName());
        this._modeleClientsConnection.addElement("Object Class [SimpleName]: " + object.getClass().getSimpleName());
        this._modeleClientsConnection.addElement("Object Class [CanonicalName]: " + object.getClass().getCanonicalName());
        this._modeleClientsConnection.addElement("Object Class [DeclaringClass]: " + object.getClass().getDeclaringClass());   
        this._modeleClientsConnection.addElement("-----------------------------------");
        if (object instanceof FactoryUC){
            jtxt_NbrConnection2.setText(String.valueOf(FactoryUC.getInstance().getNbrSubscribes()));
        }
        if (object instanceof ListeInterventions){
            jtxt_NbrInterventions.setText(String.valueOf(ListeInterventions.getInstance().nombreInterventions()));
        }
        if (object instanceof ListeClients){
            jtxt_Clients.setText(String.valueOf(ListeClients.getInstance().nombreDeClients()));
            jtxt_NombreCltP.setText(String.valueOf(ListeClients.getInstance().nombreDeClientsParticulier()));
            jtxt_NombreCltS.setText(String.valueOf(ListeClients.getInstance().nombreDeClientsSociete()));
        }
        if (object instanceof ListeTechniciens){
            jtxt_NbrTechniciens.setText(String.valueOf(ListeTechniciens.getInstance().nombreDeTechnicien()));
        }
        if (object instanceof ListeEmployesInterne){
            jtxt_NbrEmpInt.setText(String.valueOf(ListeEmployesInterne.getInstance().nombreEmployesInterne()));
        }
    }
    
}
